How to give my user permission to add/edit files on local apache server? [duplicate]

Posted by Logan on Ask Ubuntu See other posts from Ask Ubuntu or by Logan
Published on 2012-12-26T21:47:50Z Indexed on 2013/11/05 10:13 UTC
Read the original article Hit count: 331

Filed under:
|
|
|

Possible Duplicate:
How to make Apache run as current user

I'm setting up my local test server again, and I seem to have forgotten how to successfully set up the LAMP server.

I have installed LAMP server via tasksel command and I have configured the /var/www directory according to a guide I've found:

After the lamp server installation you will need write permissions to the /var/www directory. Follow these steps to configure permissions.

Add your user to the www-data group

sudo usermod -a -G www-data <your user name>

now add the /var/www folder to the www-data group

sudo chgrp -R www-data /var/www

now give write permissions to the www-data group

sudo chmod -R g+w /var/www

So logan user is now part of www-data group and the file/folder permissions look like the output below:

logan@computer:/var/www$ ls -lart
total 172
-rw-r--r--  1 www-data www-data  1997 Oct 23  2010 wp-links-opml.php
-rw-r--r--  1 www-data www-data  3177 Nov  1  2010 wp-config-sample.php
-rw-r--r--  1 www-data www-data  3700 Jan  8  2012 wp-trackback.php
-rw-r--r--  1 www-data www-data   271 Jan  8  2012 wp-blog-header.php
-rw-r--r--  1 www-data www-data   395 Jan  8  2012 index.php
-rw-r--r--  1 www-data www-data  3522 Apr 10  2012 wp-comments-post.php
-rw-r--r--  1 www-data www-data 19929 May  6  2012 license.txt
-rw-r--r--  1 www-data www-data 18219 Sep 11 08:27 wp-signup.php
-rw-r--r--  1 www-data www-data  2719 Sep 11 16:11 xmlrpc.php
-rw-r--r--  1 www-data www-data  2718 Sep 23 12:57 wp-cron.php
-rw-r--r--  1 www-data www-data  7723 Sep 25 01:26 wp-mail.php
-rw-r--r--  1 www-data www-data  2408 Oct 26 15:40 wp-load.php
-rw-r--r--  1 www-data www-data  4663 Nov 17 10:11 wp-activate.php
-rw-r--r--  1 www-data www-data  9899 Nov 22 04:52 wp-settings.php
-rw-r--r--  1 www-data www-data  9175 Nov 29 19:57 readme.html
-rw-r--r--  1 www-data www-data 29310 Nov 30 08:40 wp-login.php
drwxr-xr-x 14 root     root      4096 Dec 24 17:41 ..
drwx------  9 www-data www-data  4096 Dec 26 16:11 wp-admin
drwx------  9 www-data www-data  4096 Dec 26 16:11 wp-includes
-rw-rw-rw-  1 www-data www-data  3448 Dec 26 16:14 wp-config.php
drwxrwxr-x  5 www-data www-data  4096 Dec 26 16:14 .
drwx------  6 www-data www-data  4096 Dec 26 16:19 wp-content

Things work perfectly at http://localhost, I can view the website fine. The thing with this is that I will be working on a plugin for wordpress and I don't want to deal with separate owners under www directory to create or modify files/folders. When I give my user the ownership of /var/www recursively as logan:www-data I can create/modify files but cannot view the http://localhost. I get a Forbidden error. I'm assuming that this is because of the Apache's configuration?

Which one is healthier or easier considering this is just a local test website, configuring apache to give user logan to view website and chmod /var/www logan:logan so that I can create files etc. without any sudo commands; or is it easier to configure user groups to get www-data user to act like my logan user? (Idk how that's possible, maybe putting www-data user under logan group?)

Please shed some light to this subject. All I want is to be able to create/modifiy files under my user, and yet to be able to successfully view http://localhost I appreciate the help!

© Ask Ubuntu or respective owner

Related posts about 12.04

Related posts about permissions